package com.huawei.updatesdk.a.a.c.b.a;

import com.huawei.updatesdk.a.a.b.a.a.a;
import java.lang.reflect.InvocationTargetException;

public final class d implements a {
    private static final Object a = new Object();
    private static d b;

    private d() {
    }

    public static d b() {
        d dVar;
        synchronized (a) {
            if (b == null) {
                b = new d();
            }
            dVar = b;
        }
        return dVar;
    }

    private static Object c() {
        Object obj = null;
        try {
            Class cls = Class.forName("com.mediatek.telephony.TelephonyManagerEx");
            obj = cls.getDeclaredMethod("getDefault", new Class[0]).invoke(cls, new Object[0]);
        } catch (ClassNotFoundException e) {
            a.d("mutiCardMTKImpl", " getDefaultTelephonyManagerEx wrong " + e.toString());
        } catch (SecurityException e2) {
            a.d("mutiCardMTKImpl", " getDefaultTelephonyManagerEx wrong " + e2.toString());
        } catch (NoSuchMethodException e3) {
            a.d("mutiCardMTKImpl", " getDefaultTelephonyManagerEx wrong " + e3.toString());
        } catch (IllegalAccessException e4) {
            a.d("mutiCardMTKImpl", " getDefaultTelephonyManagerEx wrong " + e4.toString());
        } catch (IllegalArgumentException e5) {
            a.d("mutiCardMTKImpl", " getDefaultTelephonyManagerEx wrong " + e5.toString());
        } catch (InvocationTargetException e6) {
            a.d("mutiCardMTKImpl", " getDefaultTelephonyManagerEx wrong " + e6.toString());
        } catch (Exception e7) {
            a.d("mutiCardMTKImpl", " getDefaultTelephonyManagerEx wrong " + e7.toString());
        }
        return obj;
    }

    public int a() {
        Object c = c();
        if (c != null) {
            try {
                c = c.getClass().getMethod("getPreferredDataSubscription", new Class[0]).invoke(c, new Object[0]);
                if (c instanceof Integer) {
                    return ((Integer) c).intValue();
                }
            } catch (NoSuchMethodException e) {
                a.d("mutiCardMTKImpl", " getPreferredDataSubscription wrong " + e.toString());
                return -1;
            } catch (InvocationTargetException e2) {
                a.d("mutiCardMTKImpl", " getPreferredDataSubscription wrong " + e2.toString());
                return -1;
            } catch (IllegalAccessException e3) {
                a.d("mutiCardMTKImpl", " getPreferredDataSubscription wrong " + e3.toString());
                return -1;
            }
        }
        return 0;
    }
}
